<?php

namespace JLPay\Models\Openmerch\Device;

/**
 * 设备信息
 * 
 * @author liaochangyi
 * @since 2025-01-25
 */
class DeviceInfo
{
    protected ?string $deviceNo = null;  // 设备硬件序列号（SN）
    protected ?string $termNo = null;  // 终端编号
    protected ?string $merchNo = null;  // 商户号
    protected ?string $status = null;  // 状态：0-待启用 1-启用 2-停用 3-注销
    protected ?string $model = null;  // 设备型号
    protected ?string $deviceType = null;  // 设备类型：02-传统POS 04-智能POS 05-智能POS AD-音响 CD-收银台 EP-电子码牌 PT-打印机 QR-码付设备 SP-立牌
    protected ?string $supplier = null;  // 供应商
    protected ?string $merchName = null;  // 商户名称
    protected ?string $printMerchName = null;  // 打印商户名称，签购单上的商户名称
    protected ?string $address = null;  // 地址
    protected ?string $installTime = null;  // 加机时间，yyyy-mm-dd HH:mm:ss
    protected ?string $updateTime = null;  // 更新时间，yyyy-mm-dd HH:mm:ss

    /**
     * 构造函数
     *
     * @param array|null $deviceDict 设备信息字典
     */
    public function __construct(?array $deviceDict = null)
    {
        if ($deviceDict) {
            $this->deviceNo = $deviceDict['device_no'] ?? null;
            $this->termNo = $deviceDict['term_no'] ?? null;
            $this->merchNo = $deviceDict['merch_no'] ?? null;
            $this->status = $deviceDict['status'] ?? null;
            $this->model = $deviceDict['model'] ?? null;
            $this->deviceType = $deviceDict['device_type'] ?? null;
            $this->supplier = $deviceDict['supplier'] ?? null;
            $this->merchName = $deviceDict['merch_name'] ?? null;
            $this->printMerchName = $deviceDict['print_merch_name'] ?? null;
            $this->address = $deviceDict['address'] ?? null;
            $this->installTime = $deviceDict['install_time'] ?? null;
            $this->updateTime = $deviceDict['update_time'] ?? null;
        }
    }

    /**
     * 获取设备硬件序列号
     *
     * @return string|null
     */
    public function getDeviceNo(): ?string
    {
        return $this->deviceNo;
    }

    /**
     * 获取终端编号
     *
     * @return string|null
     */
    public function getTermNo(): ?string
    {
        return $this->termNo;
    }

    /**
     * 获取商户号
     *
     * @return string|null
     */
    public function getMerchNo(): ?string
    {
        return $this->merchNo;
    }

    /**
     * 获取状态
     *
     * @return string|null
     */
    public function getStatus(): ?string
    {
        return $this->status;
    }

    /**
     * 获取设备型号
     *
     * @return string|null
     */
    public function getModel(): ?string
    {
        return $this->model;
    }

    /**
     * 获取设备类型
     *
     * @return string|null
     */
    public function getDeviceType(): ?string
    {
        return $this->deviceType;
    }

    /**
     * 获取商户名称
     *
     * @return string|null
     */
    public function getMerchName(): ?string
    {
        return $this->merchName;
    }

    /**
     * 获取打印商户名称
     *
     * @return string|null
     */
    public function getPrintMerchName(): ?string
    {
        return $this->printMerchName;
    }

    /**
     * 转换为数组格式
     *
     * @return array
     */
    public function toArray(): array
    {
        return [
            'device_no' => $this->deviceNo,
            'term_no' => $this->termNo,
            'merch_no' => $this->merchNo,
            'status' => $this->status,
            'model' => $this->model,
            'device_type' => $this->deviceType,
            'supplier' => $this->supplier,
            'merch_name' => $this->merchName,
            'print_merch_name' => $this->printMerchName,
            'address' => $this->address,
            'install_time' => $this->installTime,
            'update_time' => $this->updateTime
        ];
    }
} 